﻿using System.Collections.Generic;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Media;
using CoreClasses;
using LayoutPlanning.Model;
using LayoutPlanning.Views.Machines;
using Point = LayoutPlanning.Model.Point;

namespace LayoutPlanning.Design
{
    public class SaveLoadStationRelationDesignService : ISaveLoadStationRelationService
    {
        private Station[] _stations = new Station[]
        {
            new Station()
            {
                Name = "T1",
                Position = new Point(0, 0),
                NegativeInfluence = 2,
                ControlType = ControlType.Custom,
                CustomControl = new SerializableFrameworkElement(new Machine1())
            },
            new Station()
            {
                Name = "T2",
                Position = new Point(0, 2),
                NegativeInfluence = 2,
                ControlType = ControlType.Custom,
                CustomControl = new SerializableFrameworkElement(new Machine2())
            },
            new Station()
            {
                Name = "T3",
                Position = new Point(2, 0),
                NegativeInfluence = 1,
                ControlType = ControlType.Custom,
                CustomControl = new SerializableFrameworkElement(new Machine3())
            }
        };

        private StationRelationModel _STR = new StationRelationModel();

        public Station[] Stations
        {
            get
            {
                return _stations;
            }

            set
            {
                _stations = value;
            }
        }

        public SaveLoadStationRelationDesignService()
        {
            foreach (var station in Stations)
            {
                _STR.LoadedStations.Add(station);
            }
            var s = new List<StationRelation>(new StationRelation[]
            {
                new StationRelation()
                {
                    Station1 = Stations[0],
                    Station2 = Stations[1],
                    Value = 2,
                },
                new StationRelation()
                {
                    Station1 = Stations[0],
                    Station2 = Stations[2],
                    Value = 1
                },
                new StationRelation()
                {
                    Station1 = Stations[1],
                    Station2 = Stations[2],
                    Value = -1
                }
            });
        }

        public async Task SaveStationRelationService(StationRelationModel stationrelations)
        {
            await Task.Run(() => { ; });
        }

        public async Task<StationRelationModel> LoadStationRelationService(string nametoLoad)
        {
            return await Task.Run(() => { return _STR; });
            ;
        }
    }
}